
import { nextTick } from "vue"
import "../theme/loading.scss"
export const loading = {
  // 进度开始
  start: () => {
    const body: Element = document.body
    const div = <HTMLElement>document.createElement("div")
    div.setAttribute("class", "loadingBody")
    const html = `
<div class="loading">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</div>
    `
    div.innerHTML = html
    body.insertBefore(div, body.childNodes[0])
  },
  // 进度结束
  done: () => {
    nextTick(() => {
      const el = <HTMLElement>document.querySelector('.loadingBody');
      el?.parentNode?.removeChild(el);
    })
  }
}